{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Entity</th>\n",
       "      <th>Year</th>\n",
       "      <th>percent</th>\n",
       "      <th>jy</th>\n",
       "      <th>GDP</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>2017</td>\n",
       "      <td>4.136347</td>\n",
       "      <td>2.52</td>\n",
       "      <td>10.270786</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Albania</td>\n",
       "      <td>2017</td>\n",
       "      <td>2.208414</td>\n",
       "      <td>1.62</td>\n",
       "      <td>3.163863</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Algeria</td>\n",
       "      <td>2017</td>\n",
       "      <td>3.661094</td>\n",
       "      <td>2.16</td>\n",
       "      <td>-0.547390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>American Samoa</td>\n",
       "      <td>2017</td>\n",
       "      <td>2.939668</td>\n",
       "      <td>0.41</td>\n",
       "      <td>-0.155635</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Andean Latin America</td>\n",
       "      <td>2017</td>\n",
       "      <td>2.610385</td>\n",
       "      <td>3.03</td>\n",
       "      <td>1.325673</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Andorra</td>\n",
       "      <td>2017</td>\n",
       "      <td>3.729532</td>\n",
       "      <td>0.24</td>\n",
       "      <td>2.404977</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Angola</td>\n",
       "      <td>2017</td>\n",
       "      <td>4.160484</td>\n",
       "      <td>13.89</td>\n",
       "      <td>14.820467</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Antigua and Barbuda</td>\n",
       "      <td>2017</td>\n",
       "      <td>2.557963</td>\n",
       "      <td>2.73</td>\n",
       "      <td>4.027102</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Argentina</td>\n",
       "      <td>2017</td>\n",
       "      <td>3.665488</td>\n",
       "      <td>14.69</td>\n",
       "      <td>5.655760</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Armenia</td>\n",
       "      <td>2017</td>\n",
       "      <td>2.754583</td>\n",
       "      <td>1.99</td>\n",
       "      <td>3.236465</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 Entity  Year   percent     jy        GDP\n",
       "0           Afghanistan  2017  4.136347   2.52  10.270786\n",
       "1               Albania  2017  2.208414   1.62   3.163863\n",
       "2               Algeria  2017  3.661094   2.16  -0.547390\n",
       "3        American Samoa  2017  2.939668   0.41  -0.155635\n",
       "4  Andean Latin America  2017  2.610385   3.03   1.325673\n",
       "5               Andorra  2017  3.729532   0.24   2.404977\n",
       "6                Angola  2017  4.160484  13.89  14.820467\n",
       "7   Antigua and Barbuda  2017  2.557963   2.73   4.027102\n",
       "8             Argentina  2017  3.665488  14.69   5.655760\n",
       "9               Armenia  2017  2.754583   1.99   3.236465"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import csv,os\n",
    "from pyecharts.charts import Bar,Tab,Line,Map,Timeline,Grid,Scatter\n",
    "from pyecharts import options as opts\n",
    "import pandas as pd\n",
    "import plotly.express as px\n",
    "top10= pd.read_csv('top10.csv',encoding = 'utf8')\n",
    "top10\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     2.52\n",
       "1     1.62\n",
       "2     2.16\n",
       "3     0.41\n",
       "4     3.03\n",
       "5     0.24\n",
       "6    13.89\n",
       "7     2.73\n",
       "8    14.69\n",
       "9     1.99\n",
       "Name: jy, dtype: float64"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "top10.jy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"79b0bc68215a48ef82d80d2aeeacb650\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_79b0bc68215a48ef82d80d2aeeacb650 = echarts.init(\n",
       "                    document.getElementById('79b0bc68215a48ef82d80d2aeeacb650'), 'white', {renderer: 'canvas'});\n",
       "                var option_79b0bc68215a48ef82d80d2aeeacb650 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u60a3\\u75c5\\u7387\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"Afghanistan\",\n",
       "                    4.1363471\n",
       "                ],\n",
       "                [\n",
       "                    \"Albania\",\n",
       "                    2.2084141980000003\n",
       "                ],\n",
       "                [\n",
       "                    \"Algeria\",\n",
       "                    3.661094496\n",
       "                ],\n",
       "                [\n",
       "                    \"American Samoa\",\n",
       "                    2.9396680610000003\n",
       "                ],\n",
       "                [\n",
       "                    \"Andean Latin America\",\n",
       "                    2.610385117\n",
       "                ],\n",
       "                [\n",
       "                    \"Andorra\",\n",
       "                    3.729531686\n",
       "                ],\n",
       "                [\n",
       "                    \"Angola\",\n",
       "                    4.160484197\n",
       "                ],\n",
       "                [\n",
       "                    \"Antigua and Barbuda\",\n",
       "                    2.557963052\n",
       "                ],\n",
       "                [\n",
       "                    \"Argentina\",\n",
       "                    3.6654882719999997\n",
       "                ],\n",
       "                [\n",
       "                    \"Armenia\",\n",
       "                    2.7545826960000004\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0.5\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0,\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"GDP\\u589e\\u52a0\\u503c\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"Afghanistan\",\n",
       "                    10.27078613\n",
       "                ],\n",
       "                [\n",
       "                    \"Albania\",\n",
       "                    3.1638625539999996\n",
       "                ],\n",
       "                [\n",
       "                    \"Algeria\",\n",
       "                    -0.547389546\n",
       "                ],\n",
       "                [\n",
       "                    \"American Samoa\",\n",
       "                    -0.155634548\n",
       "                ],\n",
       "                [\n",
       "                    \"Andean Latin America\",\n",
       "                    1.325672934\n",
       "                ],\n",
       "                [\n",
       "                    \"Andorra\",\n",
       "                    2.404977175\n",
       "                ],\n",
       "                [\n",
       "                    \"Angola\",\n",
       "                    14.82046663\n",
       "                ],\n",
       "                [\n",
       "                    \"Antigua and Barbuda\",\n",
       "                    4.027102125\n",
       "                ],\n",
       "                [\n",
       "                    \"Argentina\",\n",
       "                    5.655759675\n",
       "                ],\n",
       "                [\n",
       "                    \"Armenia\",\n",
       "                    3.236465499\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0.5\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0,\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u6559\\u80b2\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"Afghanistan\",\n",
       "                    2.52\n",
       "                ],\n",
       "                [\n",
       "                    \"Albania\",\n",
       "                    1.62\n",
       "                ],\n",
       "                [\n",
       "                    \"Algeria\",\n",
       "                    2.16\n",
       "                ],\n",
       "                [\n",
       "                    \"American Samoa\",\n",
       "                    0.41\n",
       "                ],\n",
       "                [\n",
       "                    \"Andean Latin America\",\n",
       "                    3.03\n",
       "                ],\n",
       "                [\n",
       "                    \"Andorra\",\n",
       "                    0.24\n",
       "                ],\n",
       "                [\n",
       "                    \"Angola\",\n",
       "                    13.89\n",
       "                ],\n",
       "                [\n",
       "                    \"Antigua and Barbuda\",\n",
       "                    2.73\n",
       "                ],\n",
       "                [\n",
       "                    \"Argentina\",\n",
       "                    14.69\n",
       "                ],\n",
       "                [\n",
       "                    \"Armenia\",\n",
       "                    1.99\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0.5\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0,\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u60a3\\u75c5\\u7387\",\n",
       "                \"GDP\\u589e\\u52a0\\u503c\",\n",
       "                \"\\u6559\\u80b2\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u60a3\\u75c5\\u7387\": true,\n",
       "                \"GDP\\u589e\\u52a0\\u503c\": true,\n",
       "                \"\\u6559\\u80b2\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"axisTick\": {\n",
       "                \"show\": true,\n",
       "                \"alignWithLabel\": true,\n",
       "                \"inside\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"boundaryGap\": false,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"Afghanistan\",\n",
       "                \"Albania\",\n",
       "                \"Algeria\",\n",
       "                \"American Samoa\",\n",
       "                \"Andean Latin America\",\n",
       "                \"Andorra\",\n",
       "                \"Angola\",\n",
       "                \"Antigua and Barbuda\",\n",
       "                \"Argentina\",\n",
       "                \"Armenia\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5341\\u4e8c\\u56fd\\u4e00\\u6b21\\u80fd\\u6e90\\u5f3a\\u5ea6\\u4e0eGDP\\u7684\\u5173\\u7cfb\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_79b0bc68215a48ef82d80d2aeeacb650.setOption(option_79b0bc68215a48ef82d80d2aeeacb650);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26e864bef28>"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def guanxi() -> Line:\n",
    "    c = (\n",
    "        Line()\n",
    "        .add_xaxis(list(top10.Entity))\n",
    "        .add_yaxis(\"患病率\",list(top10.percent), is_smooth=True)\n",
    "        .add_yaxis(\"GDP增加值\", list(top10.GDP), is_smooth=True)\n",
    "        .add_yaxis(\"教育\", list(top10.jy), is_smooth=True)\n",
    "        .set_series_opts(\n",
    "            areastyle_opts=opts.AreaStyleOpts(opacity=0.5),\n",
    "            label_opts=opts.LabelOpts(is_show=False),\n",
    "        )\n",
    "        .set_global_opts(\n",
    "            title_opts=opts.TitleOpts(title=\"十二国一次能源强度与GDP的关系\"),\n",
    "            xaxis_opts=opts.AxisOpts(\n",
    "                axistick_opts=opts.AxisTickOpts(is_align_with_label=True),\n",
    "                is_scale=False,\n",
    "                boundary_gap=False,\n",
    "            ),\n",
    "        )\n",
    "    )\n",
    "    return c\n",
    "\n",
    "guanxi().render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
